package com.jms.product.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jms.product.entity.EventEntity;
import com.jms.product.service.EventService;
import com.jms.common.utils.PageUtils;
import com.jms.common.utils.R;



/**
 *
 *
 * @author Jamison
 * @email 2982935350@qq.com
 * @date 2021-06-11 15:36:38
 */
@RestController
@RequestMapping("product/event")
public class EventController {
    @Autowired
    private EventService eventService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = eventService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{eventId}")
    public R info(@PathVariable("eventId") Integer eventId){
		EventEntity event = eventService.getById(eventId);

        return R.ok().put("event", event);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody EventEntity event){
		eventService.save(event);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody EventEntity event){
		eventService.updateById(event);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] eventIds){
		eventService.removeByIds(Arrays.asList(eventIds));

        return R.ok();
    }

}
